<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/8
 * Time: 13:46
 */
namespace app\home\controller;
use cmf\controller\UserBaseController;
use think\Db;

class FinanceController extends UserBaseController
{
    //后台看流水   督导看自己管辖的店铺       总公司看所有
    public function index()
    {
        /**搜索条件**/
       $re = $this->request->param();
       $uinfo=cmf_get_current_user();//登陆者信息
       $request = input('request.');
       $where='storeid='.$uinfo['store_id'];
       $where .= ' and userid= "'.$re['mid'].'"';
       if(!empty($request['start_time'])){
            $where .= ' and DATE( FROM_UNIXTIME( ctime ) ) >= "'.$request['start_time'].'"';
       }
       if(!empty($request['end_time'])){
           $where .= ' and DATE( FROM_UNIXTIME( ctime ) ) <= "'.$request['end_time'].'"';
       }
       $list=Db::name('finance_record')->where($where)->order("id DESC")->paginate(8);
       //echo Db::name('finance_record')->getlastsql();
      
        // 获取分页显示
       $list->appends($request);
       $this->assign("mid", $re['mid']);
       $this->assign("page", $list);
       $this->assign("uinfo", $uinfo);
       $this->assign("list", $list);
       return $this->fetch();
    }    
}